package com.icode.core.model;

import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority;

import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

/**
 * User: alexz
 * Date: 15-1-7
 * Time: 下午3:47
 */
@Entity
@DiscriminatorValue("CUSTOMER")
public class Customer extends AbstractUser {

    public Customer() {
    }

    public Customer(String username, String password) {
        super(username, password);
    }

    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        List<GrantedAuthority> authorities = new ArrayList<>();
        GrantedAuthority grantedAuthority = new SimpleGrantedAuthority("ROLE_ABOUT");
        authorities.add(grantedAuthority);
        return authorities;
    }

    @Override
    public boolean isCustomer() {
        return true;
    }
}
